Array.prototype._reduce = (function(cb,initValue){
    let array = this;
    let res = initValue || array[0];
    const startIndex = initValue ? 0: 1;
    for(let i = startIndex; i < array.length;i ++){
        const cur = array[i];
        res = cb(res,cur, i, array);
    }
    return res;
})

console.log([1,2,3,4,5]._reduce((before,after,index,arr) => before + after,null));